//引入数据库
const mysql = require('mysql')
const {MYSQL_CONF} = require('../conf/db')
//创建链接对象
const con = mysql.createConnection({
    host:"127.0.0.1",
    port:"3306",
    user:"root",
    password:"123456",
    database:"myblog"
})
//开始链接
con.connect()
//执行sql语法的函数
const exec = (sql) =>{
    return new Promise((resolve,reject) => {
        con.query(sql,(err,result) => {
            if(err){
                reject(err)
                return
            }
            console.log(result);
            resolve(result)
        })
    })
}

module.exports= {
    exec
}